#include <iostream>
class Test
{

public:
    void show()
    {
        std::cout << "hello world\n";
    }
    void lambda()
    {
        /*捕获this指针*/
        auto f = [this]()
        { this->show(); };
        f();
    }
};
int main()
{
    /*
        *[]捕获列表:捕获上下文中的变量
        *()参数列表
        *{}函数主体
        *[]() (-> int )可以不写，自动推导
        {}
    */
#if 0
    int a = 11;
    int b = 20;
    int c = 30;
    /*
     *引用捕获: &a
     *[=]:以值的形式捕获所有变量
     */
    auto f = [=, &a]()
    {
        a++;
        // b++;//不能改
        std::cout << "b = " << b << std::endl;
        std::cout << "c = " << c << std::endl;
        return 10;
    };
    std::cout << f() << std::endl;
    std::cout << "a = " << a << std::endl;
#endif
    Test t;
    t.lambda();
    return 0;
}